import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import get from '@dfeidao/atom-web/local/get';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import fire from '@dfeidao/atom-web/msg/fire';
import set_node_cls from '@dfeidao/atom-web/ui/set-node-cls';

export default async function a006(fd: IFeidaoAiBrowserComponent) {
	// todo
	const no = get(fd, 'no');
	console.log('no', no);

	const res = await nodejs<Array<{ company_no: string, company_name: string }>>('company-factory/zj-000009/s002', {});
	const arr: String[] = [];
	res.forEach((v) => {
		arr.push(v.company_no);
	});
	console.log('zj9a006arr', arr);
	for (let i = 0; i < arr.length; i++) {
		if (no === arr[i]) {
			const name = res[i].company_name;
			//console.log('zj9a006', name);
			fire('zj-000005', 'a004', name);
			fire('zj-000006', 'a005', name);
			const tc = fd.data.node.querySelector<HTMLDivElement>('[data-id="tc"]');
			set_node_cls(tc, 'display-n', true);
			return;
		}
	}
}
